<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

   <head> 
      <title>Fletag Scoreboard</title>
      <meta http-equiv="generator" content="PHP Designer 2006 - BETA" />
      <script src="sorttable.js"></script>
      <link href="default.css" rel="stylesheet" type="text/css" media="screen" />
   </head>

   <body>
         <div id="header">
	            <div id="logo">
		          <h1>FLeTaG</h1>
              </div>
         <div id="menu">
		     <ul>
             <li class="current_page_item"><a href="/fletag/scoreboard.php">Scoreboard</a></li>
			       <li><a href="http://snafu.org.uk/fletag/archive.php">Archive</a></li>
			       <li class="last"><a href="#">About</a></li>
       </ul>
	     </div>
      </div>

			<?php
			//Establish the db connection
			require('dbconn.inc.php');
			//Include the function library
			include('functions.inc.php');
			?>

			<?php
			if (!isset($_POST['submit']))
      {
       // If no specific date has been selected use todays date
       $range_date = date('Y-m-d');
      }
			else
      {
          // If user has selected a specific point in time, use that instead
          $range_date = $_POST["game_date"];
      }
      
      displayMatchResults2 ($range_date,'indoor');
      displayMatchResults2 ($range_date,'outdoor');

		 ?>
		 
   <div id="content">
        <div class="post">
             <div class="title">
                  <h2><a href="#">Match Results</a></h2>
             </div>
        </div>
   </div>
   <?php
        $match_sql = "SELECT date,
                     score1,score2,team1,team2,
                     TRUNCATE(points1,2) as team1_points,
                     TRUNCATE(points2,2) as team2_points
                     FROM games ORDER BY date DESC";
                     
        $match_result = doQuery($match_sql);
        
        $run = 0;
        
        while ($row = mysql_fetch_array($match_result))
		 		{
              $game_date = $row['date'];
              $game_score1 = $row['score1'];
              $game_score2 = $row['score2'];
              $game_team1 = $row['team1'];
              $game_team2 = $row['team2'];
              //$game_points1 = $row['team1_points'];
              //$game_points2 = $row['team2_points'];
              $game_points1 = sprintf('%.2f',calc_points2($game_score1,$game_score2));
              $game_points2 = sprintf('%.2f',calc_points2($game_score2,$game_score1));
              
              if ($run == 0)
					    {
						     print("<table BORDER cellpadding=5>");
						     print ("<form name=\"selectmatch\" action=\"$PHP_SELF\" method=\"POST\">");
						     $run = 1;
              }
              if ($range_date == $game_date)
              {
                 print ("<tr><td><input type=radio name=game_date value=$game_date checked></td>");
              }
              else
              {
                  print ("<tr><td><input type=radio name=game_date value=$game_date></td>");
              }
              print ("<td>$game_date</td><td>$game_team1</td><td>$game_score1($game_points1)</td><td>$game_score2($game_points2)</td><td>$game_team2</td></tr>");
              



        }
        print("</table><br>");
        print ("<input type=\"submit\" value=\"submit\" name=\"submit\">");
        print("</form>");
   
   ?>



   </div>
   </body>
</html>
